package com.springboot.cropsboot.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.springboot.cropsboot.entity.Admin;
import com.springboot.cropsboot.mapper.AdminMapper;
import com.springboot.cropsboot.qpage.QPage;
import com.springboot.cropsboot.service.IAdminService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.springboot.cropsboot.util.ResultView;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @since 2023-12-02
 */
@Service
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements IAdminService {

    @Override
    public ResultView getPageList(QPage qPage, Admin obj) {
        QueryWrapper<Admin> queryWrapper=new QueryWrapper<>();
        if(!StringUtils.isEmpty(obj.getAccount())){
            queryWrapper.like("account",obj.getAccount());
        }
        queryWrapper.eq("type",2);
        queryWrapper.orderByDesc("ctime");
        IPage iPage = new Page(qPage.getOffset(), qPage.getLimit());
        IPage<Admin> mapList = this.page(iPage,queryWrapper);
        return ResultView.ok(mapList);
    }


}
